/*
slub.h
**/

#ifndef __KERN_MM_SLUB_H__

#define  __KERN_MM_SLUB_H__

#include <pmm.h>

#include <list.h>

#define CACHE_NAMELEN 16

struct kmem_cache_t {

    list_entry_t slabs_full;

    list_entry_t slabs_partial;

    list_entry_t slabs_free;

    uint16_t objsize;

    uint16_t num;

    void (*ctor)(void*, struct kmem_cache_t *, size_t);

    void (*dtor)(void*, struct kmem_cache_t *, size_t);

    char name[CACHE_NAMELEN];

    list_entry_t cache_link;

};

struct kmem_cache_t *

kmem_cache_create(const char *name, size_t size,

                       void (*ctor)(void*, struct kmem_cache_t *, size_t),

                       void (*dtor)(void*, struct kmem_cache_t *, size_t));

void kmem_cache_destroy(struct kmem_cache_t *cachep);

void *kmem_cache_alloc(struct kmem_cache_t *cachep);

void *kmem_cache_zalloc(struct kmem_cache_t *cachep);

void kmem_cache_free(struct kmem_cache_t *cachep, void *objp);

size_t kmem_cache_size(struct kmem_cache_t *cachep);

const char *kmem_cache_name(struct kmem_cache_t *cachep);

int kmem_cache_shrink(struct kmem_cache_t *cachep);

int kmem_cache_reap();

void *kmalloc(size_t size);

void kfree(void *objp);

size_t ksize(void *objp);

void kmem_int();

#endif /* ! __KERN_MM_SLUB_H__ */
